<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            font-family: 'Courier New', Courier, monospace;
            font-size: 30px;
        }
        .container{
            width: max-content;
            margin: 0 auto;
            background-color: rgb(243,255,175);
            padding: 150px 100px;
            text-align: center;
        }
    </style>
    
    
    <script>
        window.onload = function(){

// 4.获取元素信息
var oDiv = document.getElementById("a");

// 5.创建变量，接收星星
var sStr = "";

// 6 遍历 循环 每行出星星
for(var i=0;i<9;){
i+=2;
for(var j=1;j<i;j++){
sStr += "*";
}

sStr +="<br>";
}
for(var i=12;i>2;){
i-=2;
for(var j=1;j<i;j++){
sStr += "*";
}

sStr +="<br>";
}

// 7.遍历 循环之外 改变盒子内部内容
oDiv.innerHTML = sStr;




}
</script>
    </script>
    
    
    
  
   
      
</head>
<body>
    <div class="container" id="a"></div>
</body>

</html>